class TFHUD extends HudCBombingRun;

var Material SWMarkerMaterial;
var texture CSymbolMat[14];
var texture UpgradeIcon[9];
var string Upgrades[9];
var() SpriteWidget CenterRadarBG;
var Actor RedBase, BlueBase;
var actor NamedActor;

var() NumericWidget Control;
var() NumericWidget MaxControl;
var() SpriteWidget UBoxIcon;
var() SpriteWidget UBoxIcon2;
var() SpriteWidget UBoxBG;
var() SpriteWidget UBoxBGDisc;
var() SpriteWidget UBoxBGDisc2;

var() NumericWidget EnergyCount;
var() NumericWidget USPCount;
var() NumericWidget SPCount;
var() SpriteWidget DBoxIcon;
var() SpriteWidget DBoxBG;
var() SpriteWidget StatBG;
var() SpriteWidget StatBG2;
var() SpriteWidget StatBG3;
var() SpriteWidget DBoxBGDisc;
var() SpriteWidget UpgradeIconWidget[9];
var bool isactive;
var basesentinel hitsent;
var float fadeTimer;
var float alpha_index;

var() texture      TaggedBeaconMat;
var() color        TaggedBeaconColor;
var() color        ObstructedTaggedColor;
var() vector       MarkerLocations[16];

/*replication
{
    unreliable if(Role==Role_Authority)
        SortMarkers,MarkerLocations;
}
*/
simulated function DrawEnemyName(Canvas C)
{
	local actor HitActor;
	local vector HitLocation,HitNormal,ViewPos;
    local int health;
    hitsent=none;
	if ( PawnOwner==none || PawnOwner.Controller == None || PawnOwner.PlayerReplicationInfo == none)
		return;
	ViewPos = PawnOwner.Location + PawnOwner.BaseEyeHeight * vect(0,0,1);
	//HitActor= trace(HitLocation,HitNormal,ViewPos+5000*vector(PawnOwner.Controller.Rotation), ViewPos,true);

	foreach TraceActors(class'Actor', HitActor, HitLocation, HitNormal, ViewPos+5000*vector(PawnOwner.Controller.Rotation), ViewPos)
	{
		if(HitActor == None || Volume(HitActor)!=none || HitActor.bHidden)
			continue;

		//Don't hit shield
		if(BigShieldSphere(HitActor)!=none)
            continue;

        break;
	}
	if(hitactor==none) return;
    if ( (xPawn(HitActor)!=none && !xpawn(HitActor).bInvis && Pawn(HitActor).PlayerReplicationInfo!=none) || tfStation(Hitactor)!=none || basesentinel(Hitactor)!=none || ShieldSphere(hitactor) != None || ShieldMesh(hitactor)!=none)
	{
        if(ShieldMesh(hitactor)!=none && ShieldMesh(hitactor).Base!=none && ShieldSentinel(ShieldMesh(hitactor).Base)!=none)
            hitactor=ShieldMesh(hitactor).Base;
	    if (ShieldSphere(hitactor) != None && (shieldsphere(hitactor)).Shield!=none && (shieldsphere(hitactor)).Shield.Sentinel != none)
	    {
	       hitactor=(shieldsphere(hitactor)).Shield.Sentinel;
	       if(sentinel(hitactor).PlayerReplicationInfo == none)
	           return;
        }
		if(tfStation(hitactor)!=none)
		{
           health=int((tfStation(hitactor).health/tfStation(hitactor).maxHealth)*100);
        }
        else if(basesentinel(hitactor) != None )
        {
            hitsent=basesentinel(hitactor);
            health=basesentinel(hitactor).health;
            if(basesentinel(hitactor).PlayerReplicationInfo!=none && basesentinel(hitactor).PlayerReplicationInfo.Team.TeamIndex==PawnOwner.PlayerReplicationInfo.Team.TeamIndex)
               isactive=true;
        }
        else if(pawn(hitactor)!=none && pawn(hitactor).playerreplicationinfo!=none)
        {
            health=pawn(hitactor).health;
        }


        PlayerOwner.ReceiveLocalizedMessage(class'TaskForces.tfHUDInfo1Msg',0,PawnOwner.PlayerReplicationInfo,,hitactor);
		PlayerOwner.ReceiveLocalizedMessage(class'TaskForces.tfHUDInfo2Msg',health,PawnOwner.PlayerReplicationInfo);
		PlayerOwner.ReceiveLocalizedMessage(class'TaskForces.tfHUDInfo3Msg',0,PawnOwner.PlayerReplicationInfo,,hitactor);


//			NameTime = Level.TimeSeconds;
//		}
		NamedActor = HitActor;
	}
	else
        isactive=false;
}

simulated function GetUpgradeNames()
{
    local int i;
    local int Checklimit;

    i=0;
    Checklimit=9;

    while(i<Checklimit)
	{
        if(sentinel(hitsent).CheckUpgrades(class 'TFMenuConsole'.default.SentinelUpgrade[i])==true)
		{
            Upgrades[i]="true";
		}
		else
		{
		    Upgrades[i]="false";
		}
		i++;
	}
}

simulated function ShowTeamScorePassA(Canvas C)
{
	local tfBaseCore B;

	if ( bShowPoints )
	{
		DrawSpriteWidget (C, TeamScoreBackground[0]);
		DrawSpriteWidget (C, TeamScoreBackground[1]);
		DrawSpriteWidget (C, TeamScoreBackgroundDisc[0]);
		DrawSpriteWidget (C, TeamScoreBackgroundDisc[1]);

        TeamScoreBackground[0].Tints[TeamIndex] = HudColorBlack;
        TeamScoreBackground[0].Tints[TeamIndex].A = 150;
        TeamScoreBackground[1].Tints[TeamIndex] = HudColorBlack;
        TeamScoreBackground[1].Tints[TeamIndex].A = 150;


		if (TeamSymbols[0].WidgetTexture != None)
			DrawSpriteWidget (C, TeamSymbols[0]);

		if (TeamSymbols[1].WidgetTexture != None)
			DrawSpriteWidget (C, TeamSymbols[1]);

        ShowVersusIcon(C);
	 	DrawNumericWidget (C, ScoreTeam[0], DigitsBig);
		DrawNumericWidget (C, ScoreTeam[1], DigitsBig);
	}

	DrawSpriteWidget (C, BombBG);
    DrawSpriteWidget (C, BombWidget.Widgets[BombWidget.BombState]);

    if ( RedBase == None )
	{
		ForEach DynamicActors(Class'tfBaseCore', B)
		{
			if ( B.myteam==0 )
				RedBase = B;
			else
				BlueBase = B;
		}
	}
	if ( RedBase != None )
	{
		C.DrawColor = RedColor;
		Draw2DLocationDot(C, RedBase.Location, 0.5 - 0.0075*HUDScale, 0.03*HUDScale, 0.027*HUDScale, 0.035*HUDScale);
	}
	if ( BlueBase != None )
	{
		C.DrawColor = BlueColor;
		Draw2DLocationDot(C, BlueBase.Location, 0.5 - 0.0075*HUDScale, 0.03*HUDScale, 0.027*HUDScale, 0.035*HUDScale);
	}
}

simulated singular function UpdateRankAndSpread(Canvas C)
{
    local tfpri pri;
    local int i, limit;
    local SpriteWidget tempWidget;

    i=0;
    limit=9;

    pri=tfPRI(pawnownerpri);

    EnergyCount.Value=pri.res;
    USPCount.Value=pri.usedcredits;
    SPCount.Value=pri.credits;

    Control.Value=tfGRI(playerowner.GameReplicationInfo).Control[pri.team.teamindex];
    MaxControl.Value=tfGRI(playerowner.GameReplicationInfo).MaxControl[pri.team.teamindex];

	DrawSpriteWidget(C,UBoxBGDisc);
	DrawSpriteWidget(C,UBoxBGDisc2);

    if(Control.Value<MaxControl.Value)
    {
        UBoxIcon.WidgetTexture=Texture'HUDContent.Generic.GlowCircle';
        UBoxIcon.Tints[0].G=255-(128*(float(Control.Value)/MaxControl.Value));
        UBoxIcon.Tints[0].R=255*(float(Control.Value)/MaxControl.Value);
        UBoxIcon.Tints[1].G=255-(128*(float(Control.Value)/MaxControl.Value));
        UBoxIcon.Tints[1].R=255*(float(Control.Value)/MaxControl.Value);
    }
    else
    {
        UBoxIcon.WidgetTexture=Finalblend'HUDContent.Generic.fb_Pulse001';
        UBoxIcon.Tints[0].G=0;
        UBoxIcon.Tints[0].R=255;
        UBoxIcon.Tints[1].G=0;
        UBoxIcon.Tints[1].R=255;
    }

    if(USPCount.Value<1000)
    {
        UBoxIcon2.WidgetTexture=Texture'HUDContent.Generic.GlowCircle';
        UBoxIcon2.Tints[0].G=255-(128*(float(USPCount.Value)/5000));
        UBoxIcon2.Tints[0].R=255*(float(USPCount.Value)/5000);
        UBoxIcon2.Tints[1].G=255-(128*(float(USPCount.Value)/5000));
        UBoxIcon2.Tints[1].R=255*(float(USPCount.Value)/5000);
    }
    else
    {
        UBoxIcon2.WidgetTexture=Finalblend'HUDContent.Generic.fb_Pulse001';
        UBoxIcon2.Tints[0].G=0;
        UBoxIcon2.Tints[0].R=255;
        UBoxIcon2.Tints[1].G=0;
        UBoxIcon2.Tints[1].R=255;
    }

    DrawSpriteWidget(C, UBoxIcon);
    DrawSpriteWidget(C, UBoxIcon2);
    //HACK these are set to fake team numbers so it shows black hud
    if(pri.team.TeamIndex==4)
    {
    UBoxIcon2.Tints[TeamIndex] = HudColorTeam[0];
	StatBG.Tints[TeamIndex] = HudColorTeam[0];
	StatBG.Tints[TeamIndex].A = 150;
	DrawSpriteWidget(C,StatBG);

	StatBG2.Tints[TeamIndex] = HudColorTeam[0];
	StatBG2.Tints[TeamIndex].A = 150;
	DrawSpriteWidget(C,StatBG2);

	StatBG3.Tints[TeamIndex] = HudColorTeam[0];
	StatBG3.Tints[TeamIndex].A = 150;
	DrawSpriteWidget(C,StatBG3);
	}
	else if(pri.team.TeamIndex==3)
	{
	UBoxIcon2.Tints[TeamIndex] = HudColorTeam[1];
	StatBG.Tints[TeamIndex] = HudColorTeam[1];
	StatBG.Tints[TeamIndex].A = 150;
	DrawSpriteWidget(C,StatBG);

	StatBG2.Tints[TeamIndex] = HudColorTeam[1];
	StatBG2.Tints[TeamIndex].A = 150;
	DrawSpriteWidget(C,StatBG2);

	StatBG3.Tints[TeamIndex] = HudColorTeam[1];
	StatBG3.Tints[TeamIndex].A = 150;
	DrawSpriteWidget(C,StatBG3);
	}
    else
    {
    UBoxIcon2.Tints[TeamIndex] = HudColorBlack;
   	StatBG.Tints[TeamIndex] = HudColorBlack;
	StatBG.Tints[TeamIndex].A = 150;
	DrawSpriteWidget(C,StatBG);

	StatBG2.Tints[TeamIndex] = HudColorBlack;
	StatBG2.Tints[TeamIndex].A = 150;
	DrawSpriteWidget(C,StatBG2);

	StatBG3.Tints[TeamIndex] = HudColorBlack;
	StatBG3.Tints[TeamIndex].A = 150;
	DrawSpriteWidget(C,StatBG3);
    }
    DrawSpriteWidget(C,DBoxBGDisc);

    DBoxIcon.WidgetTexture=CSymbolMat[pri.buildmode];
    DrawSpriteWidget(C, DBoxIcon);

    DrawNumericWidget(C, MaxControl, DigitsBig);
    DrawNumericWidget(C, Control, DigitsBig);
    DrawNumericWidget(C, USPCount, DigitsBig);
    DrawNumericWidget(C, SPCount, DigitsBig);
    DrawNumericWidget(C, EnergyCount, DigitsBig);

    if(isactive==true && sentinel(hitsent)!=none)
    {
        GetUpgradeNames();
        alpha_index=255;
        fadeTimer=Level.TimeSeconds;
    }
    else
    {
        if(Level.TimeSeconds-fadeTimer > 0.04 && alpha_index>0)
        {
           alpha_index-=12.75;
           fadeTimer=Level.TimeSeconds;
        }
    }
    if(alpha_index > 0)
    {

        while(i<limit)
        {
           if(Upgrades[i]=="true")
           {
              tempWidget=UpgradeIconWidget[i];
              tempWidget.Tints[0].A=alpha_index;
              DrawSpriteWidget(C,tempWidget);
           }
           i++;
        }
    }
}


simulated function DrawHudPassA (Canvas C)
{
    local rotator Dir;
    local float Angle, Range, MaxRange/*, AngleDelta*/;
 	local float dotsize, offsetscale, glow;
    local actor a;
    local inventory radar, scanner;
    local bool stopdraw;
    local int i;

    DrawTargeting(C);
    super.DrawHudPassA (C);
    for(i=0;i<ArrayCount(MarkerLocations);i++)
    {
        MarkerLocations[i]=tfPRI(pawnownerpri).MarkerLocations[i];
    }
    DrawTaggedPlayers(C);
	UpdateRankAndSpread(C);
	ShowTeamScorePassA(C);
	if( bShowWeaponInfo )
	{
		if (Links >0)
	        DrawNumericWidget (C, totalLinks, DigitsBig);
		totalLinks.value = Links;
	}

	radar=pawnowner.FindInventoryType(class'Taskforces.TFDepthRadar');
    scanner=pawnowner.FindInventoryType(class'Taskforces.TFLifeScanner');

    if(radar==none && scanner==none) return;

	PassStyle=STY_None;
    DrawSpriteWidget (C, CenterRadarBG);
	PassStyle=STY_Alpha;
    C.Style = ERenderStyle.STY_Alpha;

    MaxRange=2000;
    if(pawnOwner.bIsCrouched && scanner!=none) MaxRange*=3;


	foreach CollidingActors(class'actor', a, MaxRange*2, pawnowner.location)
	{
        Dir = rotator(a.Location-PawnOwner.Location);
		Range = VSize((a.Location-PawnOwner.Location)*vect(1,1,0));
		Angle = ((Dir.Yaw - PawnOwner.Rotation.Yaw) & 65535) * 6.2832/65536;

        range=fmin(MaxRange, range);
        if(range<=MaxRange)
        {
            stopdraw=false;

            if(a==pawnowner)
            {
                C.DrawColor=greencolor;
                DotSize=0.008;
                glow=250;
            }
            else if(scanner!=none && pawn(a)!=none && pawn(a).Health>0 && sentinel(a)==none)
            {
                if(pawn(a).playerreplicationinfo.team.teamindex==0)
                    C.DrawColor=redcolor;
                else C.DrawColor=bluecolor;

                DotSize=0.008;
                if(pawn(a).visibility>1) glow=220;
                else glow=100;
            }
            else if(radar!=none)
            {
                if(tfstation(a)!=none)
                {
                    if(tfstation(a).myteam==0)
                        C.DrawColor=redcolor;
                    else C.DrawColor=bluecolor;

                    C.DrawColor.G=92;

                    DotSize=0.010*tfstation(a).teamflareDS;
                    glow=150;
                }
                else if(tfminerals(a)!=none)
                {
                    C.DrawColor=purplecolor;
                    DotSize=0.015;
                    glow=100;
                }
				else if(basesentinel(a)!=none)
                {
                    C.DrawColor=purplecolor;
                   DotSize=0.010;
                    glow=150;
                }
                else if(projectile(a)!=none)
                {
                    C.DrawColor=goldcolor;
                    DotSize=0.005;
                    glow=75;
                }
                else
                {
                    C.DrawColor=whitecolor;

                    DotSize=0.0125;
                    glow=30;
                }
            }
            else stopdraw=true;

            if(!stopdraw)
            {
                C.DrawColor.A=glow*fmax(0,fmin(1,(1-VSize((a.Location-PawnOwner.Location)*vect(0,0,1))/(MaxRange/2))));

                OffsetScale=Range*0.00037575;
                if(pawnOwner.bIsCrouched && scanner!=none) OffsetScale/=3;

                C.SetPos(C.ClipX*0.35+(0.5 * C.ClipX + (0.15*OffsetScale) * C.ClipX * sin(Angle) - 0.5*DotSize*C.ClipX),
                    -C.ClipY*0.15+(0.5 * C.ClipY - (0.2*OffsetScale) * C.ClipY * cos(Angle) - 0.5*DotSize*C.ClipX));

                C.DrawTile(Material'InterfaceContent.Hud.SkinA', DotSize*C.ClipX, DotSize*C.ClipX,838,238,144,144);
            }
        }
	}
}

simulated function PostRender(Canvas C)
{
	local float tileScaleX, tileScaleY, x;
    local TFCMWhiteout w;

	if(pawnowner!=none) w=TFCMWhiteout(pawnowner.findinventorytype(class'Taskforces.TFCMWhiteout'));

    super.PostRender(c);

    if(w==none) return;

    tileScaleX = c.SizeX / 640.0f;
	tileScaleY = c.SizeY / 480.0f;

    x=fmax(0,fmin(255,255*(w.amount/8)));

    c.DrawColor.R = x;
    c.DrawColor.G = x;
	c.DrawColor.B = x;
	c.DrawColor.A = x;

    c.Style = ERenderStyle.STY_Alpha;
	c.SetPos(0,0);
    c.DrawTile( Material'TFMedia.TFCMWhiteoutRot', c.SizeX, c.SizeY, 0.0, 0.0, 512, 512 );
}

simulated function DrawTargeting( Canvas C )
{
    local int XPos, YPos;
    local vector ScreenPos;
    local vector X,Y,Z,Dir;
    local float RatioX, RatioY;
    local float tileX, tileY;
    local float Dist;
    local float SizeX;
    local float SizeY;
    local controller p;

    GetAxes(PlayerOwner.Rotation, X,Y,Z);
    RatioX = C.SizeX / 640.0;
    RatioY = C.SizeY / 480.0;

    for ( P = Level.ControllerList; P!=None; P=P.nextController )
    {
        if(p.pawn!=none && p.Pawn!=pawnowner && fasttrace(p.Pawn.location,pawnowner.location+vect(0,0,1)*pawnowner.eyeheight) &&
            p.pawn.health>0 && tfpri(p.playerreplicationinfo)!=none && p.pawn.FindInventoryType(class'Taskforces.TFWLGun')!=none)
		{
			Dir = p.Pawn.location - PawnOwner.Location;
	        Dist = VSize(Dir);
	        Dir = Dir/Dist;
            SizeX = (512/dist) * 96.0;
            SizeY = (512/dist) * 96.0;
            ScreenPos = C.WorldToScreen( p.Pawn.location );
            tileX = sizeX * RatioX;
            tileY = sizeY * RatioX;

            if ( (Dir dot X) > 0.0 ) // don't draw if it's behind the eye
			{
				XPos = ScreenPos.X;
				YPos = ScreenPos.Y;
    		    C.Style = ERenderStyle.STY_Additive;
                C.DrawColor.R = 255;
                C.DrawColor.B = 255;
    		    C.DrawColor.G = 255;
    		    C.DrawColor.A = 255;
				C.SetPos(XPos - tileX*0.5, YPos - tileY*0.5);
    		    C.DrawTile( SWMarkerMaterial, tileX, tileY, 0.0, 0.0, 256, 256);
			}
		}
	}
}
simulated function DrawTaggedPlayers(Canvas C)
{
    local int           i;
    local vector        ScreenPos;
    local vector        CamLoc;
    local rotator       CamRot;
 //   local TFGRI         tfgri;
//    local float         ProgressPct;

    //tfgri = PawnOwner.PRI;
    for(i=0;i<ArrayCount(MarkerLocations);i++)
    {
        C.DrawColor = HudColorBlue;
        C.Style     = ERenderStyle.STY_Alpha;
        C.GetCameraLocation( CamLoc, CamRot );
//        ProgressPct = float(tfgri.TaggedPlayerHealth[i]) / 100;

        if ( IsTargetInFrontOfPlayer( C, MarkerLocations[i], ScreenPos, CamLoc, CamRot ) && MarkerLocations[i] != vect(0, 0, 0) )
        {
            DrawLocationTracking_Obstructed( C, MarkerLocations[i], false, CamLoc, ScreenPos );
        }
    }

/*
    ForEach DynamicActors(class'Pawn',P)
        if ( P.Health > 0 )
        {
            IsLocationVisible( C, P.Location, ScreenPos, CamLoc, CamRot );
            DrawLocationTracking_Obstructed( C, P.Location, false, CamLoc, ScreenPos );
        }
*/
}

simulated function DrawLocationTracking_Obstructed( Canvas C, Vector A, bool bOptionalIndicator, vector CamLoc, out vector ScreenPos )
{
    local String    DistanceText;
    local float     XL, YL, tileX, tileY, width, height;
    local vector    IndicatorPos;

    C.Style         = ERenderStyle.STY_Alpha;
    DistanceText    = "[ " $ int(VSize(A-CamLoc)*0.01875.f) $ " m ]";
    C.Font          = GetConsoleFont( C );

    C.StrLen(DistanceText, XL, YL);
    XL = XL*0.5;
    YL = YL*0.5;

    tileX   = 64.f * 0.45 * ResScaleX * HUDScale;
    tileY   = 64.f * 0.45 * ResScaleY * HUDScale;

    width   = FMax(tileX*0.5, XL);
    height  = tileY*0.5 + YL*2;
    ClipScreenCoords( C, ScreenPos.X, ScreenPos.Y, width, height );

    // Objective Icon
    IndicatorPos.X = ScreenPos.X;
    IndicatorPos.Y = ScreenPos.Y - height + YL + tileY*0.5;
    DrawObstructedIcon( C, bOptionalIndicator, IndicatorPos.X - tileX*0.5, IndicatorPos.Y - tileY*0.5, tileX, tileY );

    // Distance reading
    C.SetPos(IndicatorPos.X - XL, IndicatorPos.Y + tileY*0.5 );
    C.DrawText(DistanceText, false);

    ScreenPos = IndicatorPos;
}

simulated function DrawObstructedIcon( Canvas C, bool bOptionalObjective, float posX, float posY, float tileX, float tileY )
{
    C.SetPos(posX, posY);
    C.DrawColor = ObstructedTaggedColor;

    C.DrawTile( TexRotator'HUDContent.Reticles.rotReticle001', tileX, tileY, 0.f, 0.f, 256, 256);
}

static function Color GetGYRColorRamp( float Pct )
{
    local Color GYRColor;

    GYRColor.A = 255;

    if ( Pct < 0.34 )
    {
        GYRColor.R = 128 + 127 * FClamp(3.f*Pct, 0.f, 1.f);
        GYRColor.G = 0;
        GYRColor.B = 0;
    }
    else if ( Pct < 0.67 )
    {
        GYRColor.R = 255;
        GYRColor.G = 255 * FClamp(3.f*(Pct-0.33), 0.f, 1.f);
        GYRColor.B = 0;
    }
    else
    {
        GYRColor.R = 255 * FClamp(3.f*(1.f-Pct), 0.f, 1.f);
        GYRColor.G = 255;
        GYRColor.B = 0;
    }

    return GYRColor;
}

static function ClipScreenCoords( Canvas C, out float X, out float Y, optional float XL, optional float YL )
{
    if ( X < XL ) X = XL;
    if ( Y < YL ) Y = YL;
    if ( X > C.ClipX - XL ) X = C.ClipX - XL;
    if ( Y > C.ClipY - YL ) Y = C.ClipY - YL;
}

simulated final function bool IsLocationVisible( Canvas C, Vector Target, out vector ScreenPos,
                                                 Vector CamLoc, Rotator CamRot )
{
    local vector        TargetLocation, TargetDir;
    local float         Dist;

    Dist = VSize(Target - CamLoc);

    // Target is located behind camera
    if ( !IsTargetInFrontOfPlayer( C, Target, ScreenPos, CamLoc, CamRot ) )
        return false;

    // Simple Line check to see if we hit geometry
    TargetDir       = Target - CamLoc;
    TargetDir.Z     = 0;
//    TargetLocation  = Target.Location - 2.f * Target.CollisionRadius * vector(rotator(TargetDir));
    TargetLocation  = Target - 2.f * 32 * vector(rotator(TargetDir));

    if ( !FastTrace( TargetLocation, CamLoc ) )
        return false;

    return true;
}

/* returns true if target is projected on visible canvas area */
static function bool IsTargetInFrontOfPlayer( Canvas C, Vector Target, out Vector ScreenPos,
                                             Vector CamLoc, Rotator CamRot )
{
    // Is Target located behind camera ?
    if ( (Target - CamLoc) Dot vector(CamRot) < 0)
        return false;

    // Is Target on visible canvas area ?
    ScreenPos = C.WorldToScreen( Target );
    if ( ScreenPos.X <= 0 || ScreenPos.X >= C.ClipX ) return false;
    if ( ScreenPos.Y <= 0 || ScreenPos.Y >= C.ClipY ) return false;

    return true;
}


defaultproperties
{
     SWMarkerMaterial=FinalBlend'TFMedia.Nuke.TFSWMarker'
     CSymbolMat(0)=Texture'TFMedia.Misc.CSymbolShield'
     CSymbolMat(1)=Texture'TFMedia.Misc.CSymbolProtector'
     CSymbolMat(2)=Texture'TFMedia.Misc.CSymbolPortal'
     CSymbolMat(3)=Texture'TFMedia.Misc.CSymbolArmory'
     CSymbolMat(4)=Texture'TFMedia.Misc.CSymbolGenerator'
     CSymbolMat(5)=Texture'TFMedia.Misc.CSymbolOutpost'
     CSymbolMat(6)=Texture'TFMedia.Misc.CSymbolMedivac'
     CSymbolMat(7)=Texture'TFMedia.Misc.CSymbolRepair'
     CSymbolMat(8)=Texture'TFMedia.Misc.CSymbolRecycle'
     CSymbolMat(9)=Texture'TFMedia.Misc.CSymbolUpgrade'
     CSymbolMat(10)=Texture'TFMedia.Misc.CSymbolDropRes'
     CSymbolMat(11)=texture'TFMedia.Misc.CSymbolSentinel'
     CSymbolMat(12)=texture'TFMedia.Misc.CSymbolSentinel'
     CSymbolMat(13)=texture'TFMedia.Misc.CSymbolSentinel'
     Upgrades(0)="false"
     Upgrades(1)="false"
     Upgrades(2)="false"
     Upgrades(3)="false"
     Upgrades(4)="false"
     Upgrades(5)="false"
     Upgrades(6)="false"
     Upgrades(7)="false"
     Upgrades(8)="false"
     CenterRadarBG=(WidgetTexture=Texture'InterfaceContent.HUD.SkinA',RenderStyle=STY_Alpha,TextureCoords=(X1=142,Y1=880,Y2=1023),TextureScale=1.150000,DrawPivot=DP_MiddleMiddle,PosX=0.850000,PosY=0.350000,ScaleMode=SM_Right,Scale=1.000000,Tints[0]=(B=255,G=255,R=255,A=110),Tints[1]=(B=255,G=255,R=255,A=110))
     Control=(RenderStyle=STY_Alpha,TextureScale=0.300000,DrawPivot=DP_MiddleLeft,PosX=0.095000,PosY=0.030000,Tints[0]=(B=200,G=255,R=255,A=255),Tints[1]=(B=200,G=255,R=255,A=222))
     MaxControl=(RenderStyle=STY_Alpha,TextureScale=0.300000,DrawPivot=DP_MiddleLeft,PosX=0.060000,PosY=0.010000,Tints[0]=(B=64,G=64,R=255,A=128),Tints[1]=(B=64,G=64,R=255,A=128))
     UBoxIcon=(WidgetTexture=Texture'HUDContent.Generic.GlowCircle',RenderStyle=STY_Alpha,TextureCoords=(X1=0,Y1=0,X2=64,Y2=64),TextureScale=0.430000,PosX=0.022500,PosY=0.0130,ScaleMode=SM_Left,Scale=1.000000,Tints[0]=(G=255,A=255),Tints[1]=(G=255,A=255))
     UBoxIcon2=(WidgetTexture=Texture'HUDContent.Generic.GlowCircle',RenderStyle=STY_Alpha,TextureCoords=(X1=0,Y1=0,X2=64,Y2=64),TextureScale=0.430000,PosX=0.022500,PosY=0.110000,ScaleMode=SM_Left,Scale=1.000000,Tints[0]=(G=255,A=255),Tints[1]=(G=255,A=255))
     UBoxBG=(WidgetTexture=Texture'HUDContent.Generic.HUD',RenderStyle=STY_Alpha,TextureCoords=(X1=119,Y1=258,X2=173,Y2=313),TextureScale=0.530000,PosY=0.012000,ScaleMode=SM_Left,Scale=1.000000,Tints[0]=(B=255,G=255,R=255,A=255),Tints[1]=(B=255,G=255,R=255,A=255))
     StatBG=(WidgetTexture=Texture'TFMedia.HUD.Statbar',RenderStyle=STY_Alpha,TextureCoords=(X1=0,Y1=0,X2=511,Y2=254),TextureScale=0.250000,PosY=0.00000,ScaleMode=SM_Left,Scale=1.0000000,Tints[0]=(B=255,G=255,R=255,A=255),Tints[1]=(B=255,G=255,R=255,A=255))
     StatBG2=(WidgetTexture=Texture'TFMedia.HUD.Statbar',RenderStyle=STY_Alpha,TextureCoords=(X1=0,Y1=0,X2=511,Y2=254),TextureScale=0.250000,PosX=0.06400000,PosY=0.0480000,ScaleMode=SM_Left,Scale=1.0000000,Tints[0]=(B=255,G=255,R=255,A=255),Tints[1]=(B=255,G=255,R=255,A=255))
     StatBG3=(WidgetTexture=Texture'TFMedia.HUD.Statbarflip',RenderStyle=STY_Alpha,TextureCoords=(X1=0,Y1=0,X2=512,Y2=256),TextureScale=0.250000,PosY=0.0450000,ScaleMode=SM_Left,Scale=1.0000000,Tints[0]=(B=255,G=255,R=255,A=255),Tints[1]=(B=255,G=255,R=255,A=255))
     UBoxBGDisc=(WidgetTexture=Texture'TFMedia.HUD.RadarCircles',RenderStyle=STY_Alpha,TextureCoords=(X1=0,Y1=128,X2=128,Y2=255),TextureScale=0.230000,PosX=0.02000000,PosY=0.010000,ScaleMode=SM_Left,Scale=1.000000,Tints[0]=(B=255,G=255,R=255,A=255),Tints[1]=(B=255,G=255,R=255,A=255))
     UBoxBGDisc2=(WidgetTexture=Texture'TFMedia.HUD.RadarCircles',RenderStyle=STY_Alpha,TextureCoords=(X1=0,Y1=128,X2=128,Y2=255),TextureScale=0.230000,PosX=0.02100000,PosY=0.108000,ScaleMode=SM_Left,Scale=1.000000,Tints[0]=(B=255,G=255,R=255,A=255),Tints[1]=(B=255,G=255,R=255,A=255))
     EnergyCount=(RenderStyle=STY_Alpha,TextureScale=0.400000,DrawPivot=DP_MiddleLeft,PosX=0.1500000,PosY=0.075000,Tints[0]=(B=255,G=222,R=200,A=255),Tints[1]=(B=255,G=222,R=200,A=255))
     USPCount=(RenderStyle=STY_Alpha,TextureScale=0.300000,DrawPivot=DP_MiddleLeft,PosX=0.1000000,PosY=0.170000,Tints[0]=(B=36,G=127,R=255,A=128),Tints[1]=(B=36,G=127,R=255,A=128))
     SPCount=(RenderStyle=STY_Alpha,TextureScale=0.300000,DrawPivot=DP_MiddleLeft,PosX=0.067000,PosY=0.150000,Tints[0]=(B=222,G=255,R=200,A=255),Tints[1]=(B=222,G=255,R=200,A=222))
     DBoxIcon=(WidgetTexture=Texture'HUDContent.Generic.HUD',RenderStyle=STY_Alpha,TextureCoords=(X1=0,Y1=0,X2=128,Y2=128),TextureScale=0.280000,PosX=0.08000,PosY=0.05300,ScaleMode=SM_Left,Scale=1.000000,Tints[0]=(B=255,G=255,R=255,A=255),Tints[1]=(B=255,G=255,R=255,A=255))
     DBoxBG=(WidgetTexture=Texture'HUDContent.Generic.HUD',RenderStyle=STY_Alpha,TextureCoords=(X1=168,Y1=211,X2=334,Y2=255),TextureScale=0.530000,PosY=0.072000,ScaleMode=SM_Left,Scale=1.000000,Tints[0]=(B=255,G=255,R=255,A=255),Tints[1]=(B=255,G=255,R=255,A=255))
     DBoxBGDisc=(WidgetTexture=Texture'TFMedia.HUD.RadarCircles',RenderStyle=STY_Alpha,TextureCoords=(X1=0,Y1=128,X2=128,Y2=255),TextureScale=0.230000,PosX=0.08500000,PosY=0.058000,ScaleMode=SM_Left,scale=1.000000,Tints[0]=(B=255,G=255,R=255,A=255),Tints[1]=(B=255,G=255,R=255,A=255))
     BombWidget=(Widgets[0]=(TextureCoords=(X1=365,Y1=234,X2=431,Y2=312),TextureScale=0.350000,OffsetY=20))
     bDrawTimer=False
     UpgradeIconWidget(0)=(WidgetTexture=Texture'TFMedia.Misc.Armor',RenderStyle=STY_Alpha,TextureCoords=(X1=0,Y1=0,X2=128,Y2=128),TextureScale=0.280000,PosX=0.16,PosY=0.85,ScaleMode=SM_Left,scale=1.000000,Tints[0]=(B=255,G=255,R=255,A=255),Tints[1]=(B=255,G=255,R=255,A=255))
     UpgradeIconWidget(1)=(WidgetTexture=Texture'TFMedia.Misc.Cloak',RenderStyle=STY_Alpha,TextureCoords=(X1=0,Y1=0,X2=128,Y2=128),TextureScale=0.280000,PosX=0.24,PosY=0.85,ScaleMode=SM_Left,Scale=1.000000,Tints[0]=(B=255,G=255,R=255,A=255),Tints[1]=(B=255,G=255,R=255,A=255))
     UpgradeIconWidget(2)=(WidgetTexture=Texture'TFMedia.Misc.CPU',RenderStyle=STY_Alpha,TextureCoords=(X1=0,Y1=0,X2=128,Y2=128),TextureScale=0.280000,PosX=0.32,PosY=0.85,ScaleMode=SM_Left,scale=1.000000,Tints[0]=(B=255,G=255,R=255,A=255),Tints[1]=(B=255,G=255,R=255,A=255))
     UpgradeIconWidget(3)=(WidgetTexture=Texture'TFMedia.Misc.Motor',RenderStyle=STY_Alpha,TextureCoords=(X1=0,Y1=0,X2=128,Y2=128),TextureScale=0.280000,PosX=0.40,PosY=0.85,ScaleMode=SM_Left,Scale=1.000000,Tints[0]=(B=255,G=255,R=255,A=255),Tints[1]=(B=255,G=255,R=255,A=255))
     UpgradeIconWidget(4)=(WidgetTexture=Texture'TFMedia.Misc.Network',RenderStyle=STY_Alpha,TextureCoords=(X1=0,Y1=0,X2=128,Y2=128),TextureScale=0.280000,PosX=0.48,PosY=0.85,ScaleMode=SM_Left,Scale=1.000000,Tints[0]=(B=255,G=255,R=255,A=255),Tints[1]=(B=255,G=255,R=255,A=255))
     UpgradeIconWidget(5)=(WidgetTexture=Texture'TFMedia.Misc.SelfDestruct',RenderStyle=STY_Alpha,TextureCoords=(X1=0,Y1=0,X2=128,Y2=128),TextureScale=0.280000,PosX=0.56,PosY=0.85,ScaleMode=SM_Left,Scale=1.000000,Tints[0]=(B=255,G=255,R=255,A=255),Tints[1]=(B=255,G=255,R=255,A=255))
     UpgradeIconWidget(6)=(WidgetTexture=Texture'TFMedia.Misc.Sensor',RenderStyle=STY_Alpha,TextureCoords=(X1=0,Y1=0,X2=128,Y2=128),TextureScale=0.280000,PosX=0.64,PosY=0.85,ScaleMode=SM_Left,Scale=1.000000,Tints[0]=(B=255,G=255,R=255,A=255),Tints[1]=(B=255,G=255,R=255,A=255))
     UpgradeIconWidget(7)=(WidgetTexture=Texture'TFMedia.Misc.MShield',RenderStyle=STY_Alpha,TextureCoords=(X1=0,Y1=0,X2=128,Y2=128),TextureScale=0.280000,PosX=0.72,PosY=0.85,ScaleMode=SM_Left,Scale=1.000000,Tints[0]=(B=255,G=255,R=255,A=255),Tints[1]=(B=255,G=255,R=255,A=255))
     UpgradeIconWidget(8)=(WidgetTexture=Texture'TFMedia.Misc.Telemetry',RenderStyle=STY_Alpha,TextureCoords=(X1=0,Y1=0,X2=128,Y2=128),TextureScale=0.280000,PosX=0.80,PosY=0.85,ScaleMode=SM_Left,scale=1.000000,Tints[0]=(B=255,G=255,R=255,A=255),Tints[1]=(B=255,G=255,R=255,A=255))
     TaggedBeaconMat=Texture'TeamSymbols.TeamBeaconT'
     TaggedBeaconColor=(R=255,A=255)
     ObstructedTaggedColor=(R=255,A=255)
}
